package com.github.xiaolyuh.exception;

import com.github.xiaolyuh.enums.CacheCodeEnum;

/**
 * 缓存异常
 *
 * @author xuwanglong
 */
public class CacheException extends Exception {

	private static final long serialVersionUID = 1L;

	/**
	 * 错误代码
	 */
	private Integer code;

	/**
	 * 错误详情
	 */
	private String detailMsg;

	public CacheException(CacheCodeEnum promotionCodeEnum) {
		this(promotionCodeEnum.getCode(), promotionCodeEnum.getText());
	}

	public CacheException(CacheCodeEnum promotionCodeEnum, Throwable cause) {
		this(promotionCodeEnum.getCode(), promotionCodeEnum.getText(), cause);
	}

	public CacheException(Integer code, String detailMsg) {
		this(code, detailMsg, new Exception(detailMsg));
	}

	public CacheException(Integer code, String detailMsg, Throwable cause) {
		super(cause);
		this.code = code;
		this.detailMsg = detailMsg;
	}

	public Integer getCode() {
		return code;
	}

	public void setCode(Integer code) {
		this.code = code;
	}

	public String getDetailMsg() {
		return detailMsg;
	}

	public void setDetailMsg(String detailMsg) {
		this.detailMsg = detailMsg;
	}

}